// formPackage/pages/invite/inviteList/inviteList.js
import { queryAllInviteList } from "../../../../service/invite_service"
let app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    themeStyle: "",
    page: 0,
    pageSize: 200,
    inviteList: [

    ],
    isShowFloorPopup: false,
    showFilterPop: false,
    words: "",
    salary: "",
    experience: "",
    education: "",
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.queryAllInviteList();
  },



  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    if (app.globalData.themeStyle) {
      this.setData({
        themeStyle: app.globalData.themeStyle
      })
    }
  },
  //查询所有招募列表
  queryAllInviteList() {
    wx.showLoading();
    queryAllInviteList(this.data.page, this.data.pageSize, this.data.words, this.data.salary, this.data.experience, this.data.education).then(res => {
      wx.hideLoading();
      console.log("JJLog:招募列表是:" + JSON.stringify(res));
      if (res.code == 200) {
        this.setData({
          inviteList: res.data
        })
      }
    }).catch(err => {
      console.error("JJLog:queryAllInviteList", err);
      wx.hideLoading();
      wx.showToast({
        title: err || "获取失败",
        icon: "none"
      })
    })
  },
  //跳转到详情：
  pushToDetail(e) {
    let id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: '/formPackage/pages/invite/inviteDetail/inviteDetail?id=' + id,
    })
  },

  //搜索列表
  searchAction(e) {
    this.setData({
      words: e.detail.searchWord,

    })
    this.queryAllInviteList();
  },
  hidePopup() {
    this.setData({
      isShowFloorPopup: false
    })
  },
  //筛选回调
  floorPopupSelect(e) {
    let result = e.detail.result;
    console.log("JJLog:回调结果是:" + JSON.stringify(result));
    let salary = result[0].value;//薪资
    let experience = result[1].value;//工作年限
    let education = result[2].value;//学历
    this.setData({
      salary: salary,
      experience: experience,
      education: education,
    })
    this.queryAllInviteList();

    this.hidePopup();
  },
  filterJobAction() {
    this.setData({
      isShowFloorPopup: !this.data.isShowFloorPopup
    })
  },





})